﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WS.EKA.ServiceInterface;
using WS.EKA.Model;
using WS.EKA.DataAccess;

namespace WS.EKA.ServiceImpl
{
    public class MemberAddressService:IMemberAddress
    {
        public List<MemberAddress> GetListByMember(string loginId)
        {
            return MemberAddressContext.GetByConditions(t => t.MemLoginID == loginId, x => x.OrderByDescending(t => t.ModifyTime));
        }

        public void Add(MemberAddress address)
        {
            var model = MemberAddressContext.Get(
                t => t.Address == address.Address &&
                    t.Email == address.Email &&
                    t.Mobile == address.Mobile &&
                    t.Tel == address.Tel &&
                    t.NAME == address.NAME &&
                    t.Postalcode == address.Postalcode);
            if (model == null)
            {
                MemberAddressContext.Add(address);
            }
        }
    }
}
